/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/16
\**********************/
#include "LuaHotKey.h"

#define CObjPtr ((CHotKeyUI*)m_cobj)

namespace DuiLib {

void LuaHotKey::SetEnabled(bool bEnable)
{
    CObjPtr->SetEnabled(bEnable);
}

int LuaHotKey::SetText(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetText(str.c_str());
    return 0;
}

int LuaHotKey::GetNormalImage(LuaState *L)
{
    SDTString str = CObjPtr->GetNormalImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaHotKey::SetNormalImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetNormalImage(str.c_str());
    return 0;
}

int LuaHotKey::GetHotImage(LuaState *L)
{
    SDTString str = CObjPtr->GetHotImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaHotKey::SetHotImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetHotImage(str.c_str());
    return 0;
}

int LuaHotKey::GetFocusedImage(LuaState *L)
{
    SDTString str = CObjPtr->GetFocusedImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaHotKey::SetFocusedImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetFocusedImage(str.c_str());
    return 0;
}

int LuaHotKey::GetDisabledImage(LuaState *L)
{
    SDTString str = CObjPtr->GetDisabledImage();
    LuaHelperNS::PushTString(L, str);
    return 1;
}

int LuaHotKey::SetDisabledImage(LuaState *L)
{
    LuaStack args(L);
    SDTString str = LuaHelperNS::GetTString(args[2]);
    CObjPtr->SetDisabledImage(str.c_str());
    return 0;
}

void LuaHotKey::SetNativeBkColor(DWORD dwBkColor)
{
    CObjPtr->SetNativeBkColor(dwBkColor);
}

DWORD LuaHotKey::GetNativeBkColor()
{
    return CObjPtr->GetNativeBkColor();
}

int LuaHotKey::SetPos(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    CObjPtr->SetPos(rc);
    return 0;
}

void LuaHotKey::SetVisible(bool bVisible)
{
    CObjPtr->SetVisible(bVisible);
}

void LuaHotKey::SetInternVisible(bool bVisible)
{
    CObjPtr->SetInternVisible(bVisible);
}

int LuaHotKey::EstimateSize(LuaState *L)
{
    LuaStack args(L);
    SIZE szAvailable = LuaHelperNS::GetSize(args[2]);
    SIZE sz = CObjPtr->EstimateSize(szAvailable);
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

int LuaHotKey::GetHotKey(LuaState *L)
{
    LuaStack args(L);
    WORD wVirtualKeyCode = 0;
    WORD wModifiers = 0;
    CObjPtr->GetHotKey(wVirtualKeyCode, wModifiers);
    L->PushInteger(wVirtualKeyCode);
    L->PushInteger(wModifiers);
    return 2;
}

void LuaHotKey::SetHotKey(WORD wVirtualKeyCode, WORD wModifiers)
{
    CObjPtr->SetHotKey(wVirtualKeyCode, wModifiers);
}

SDLUA_BEGIN_REGISTER(LuaHotKey, HotKey, Label)
    SDLUA_REGISTER_FUN_CPP(LuaHotKey, SetEnabled, SetEnabled)
    SDLUA_REGISTER_FUN_LUA(LuaHotKey, SetText, SetText)

    SDLUA_REGISTER_FUN_LUA(LuaHotKey, GetNormalImage, GetNormalImage)
    SDLUA_REGISTER_FUN_LUA(LuaHotKey, SetNormalImage, SetNormalImage)
    SDLUA_REGISTER_FUN_LUA(LuaHotKey, GetHotImage, GetHotImage)
    SDLUA_REGISTER_FUN_LUA(LuaHotKey, SetHotImage, SetHotImage)
    SDLUA_REGISTER_FUN_LUA(LuaHotKey, GetFocusedImage, GetFocusedImage)
    SDLUA_REGISTER_FUN_LUA(LuaHotKey, SetFocusedImage, SetFocusedImage)
    SDLUA_REGISTER_FUN_LUA(LuaHotKey, GetDisabledImage, GetDisabledImage)
    SDLUA_REGISTER_FUN_LUA(LuaHotKey, SetDisabledImage, SetDisabledImage)

    SDLUA_REGISTER_FUN_CPP(LuaHotKey, SetNativeBkColor, SetNativeBkColor)
    SDLUA_REGISTER_FUN_CPP(LuaHotKey, GetNativeBkColor, GetNativeBkColor)

    SDLUA_REGISTER_FUN_LUA(LuaHotKey, SetPos, SetPos)
    SDLUA_REGISTER_FUN_CPP(LuaHotKey, SetInternVisible, SetInternVisible)
    SDLUA_REGISTER_FUN_CPP(LuaHotKey, SetVisible, SetVisible)
    SDLUA_REGISTER_FUN_LUA(LuaHotKey, EstimateSize, EstimateSize)

    SDLUA_REGISTER_FUN_LUA(LuaHotKey, GetHotKey, GetHotKey)
    SDLUA_REGISTER_FUN_CPP(LuaHotKey, SetHotKey, SetHotKey)

SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaHotKey, HotKey)
SDLUA_END_UNREGISTER(HotKey)

}

#undef CObjPtr